#include <iostream>

using namespace std;
const int N=1e6+10;

int tree[N],cur;
int main()
{
	int n;
	cin>>n;
	cur=1;
	int maxn=0;
	for(int i=0;i<n;i++)
	{
		int num;
		cin>>num;
		cur=1;
		while(tree[cur])
		{
			if(num>tree[cur])
			{
				cur=cur*2;
			}
			else{
				cur=cur*2+1;
			}
		}
		tree[cur]=num;
		maxn=max(maxn,cur);
		
	}
	bool flg=true;
	for(int i=1;i<=maxn;i++)
	{
		if(tree[i])
		{
			if(i>1)
			{
				cout<<' '<<tree[i];
			}
			else{
				cout<<tree[i];
			}
		}
		else{
			flg=false;
		}
	}
	cout<<endl;
	if(flg)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}
